package model.mediators;

import java.util.Iterator;

import model.core.GameScheduler;
import model.entity.Entity;

public class InteractiveMediator extends InteractionMenuMediator {

	
	/**
	 * @param activeEntity
	 * @param passiveEntity
	 */
	public InteractiveMediator(Entity activeEntity, Entity passiveEntity) {
		this.activeEntity = activeEntity;
		this.passiveEntity = passiveEntity;
		createWindow();
	}
	
	private Entity activeEntity;
	private Entity passiveEntity;
	private WindowedInteraction window;
	
	private void createWindow() {
		GameScheduler.getInstance().stopTimer();
		window = new WindowedInteraction("Interaction Menu", this);
		Iterator<InteractionOption> activeIterator = activeEntity.getByInteractiveList().iterator();
		while (activeIterator.hasNext()) {
			InteractionOption option = activeIterator.next();
			option.parameterize(activeEntity, passiveEntity, this);
			window.addButton(option);
			
		
		}
		
		Iterator<InteractionOption> passiveIterator = passiveEntity.getWithInteractiveList().iterator();
		
		while (activeIterator.hasNext()) {
			InteractionOption option = passiveIterator.next();
			option.parameterize(activeEntity, passiveEntity, this);
			window.addButton(option);
		}
		
		
		window.createWindow();
	}
	
	public void show() {
		window.showWindow();
	}
	
	public void hide() {
		window.hideWindow();
	}
	public void exit() {
	GameScheduler.getInstance().stopTimer();
	}
	
	
}
